<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>DTChat - Annotation</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <script src="shared.js"></script>
    <script src="browsercheck.js"></script>
    <script src="emoticons.js"></script>
    <script src="switchStyle.js"></script>
    <script src="xmlextras.js"></script>
    <script src="JSJaCPacket.js"></script>
    <script>
      <!--
var srcW, jid;
function init() {
  srcW = opener;

  getArgs();

  if (typeof(passedArgs['jid']) == 'undefined')
    return;

  jid = passedArgs['jid'];

	var user = srcW.roster.getUserByJID(jid);
	if (!user)
		return; // unbelievable

  var titleStr = "Annotations for "+user.name;
  document.title = titleStr;
  document.getElementById('title').innerHTML = titleStr;

  if (srcW.annotations[jid])
    document.getElementById('note').value = srcW.annotations[jid];
}

function saveNotes() {
  // save note
  srcW.annotations[jid] = document.getElementById('note').value;

	var iq = new JSJaCIQ();
	iq.setType('set');
	var query = iq.setQuery('jabber:iq:private');
	var jNode = query.appendChild(iq.getDoc().createElement('jwchat'));
	jNode.setAttribute('xmlns','jwchat:notes');

	for (var i in srcW.annotations)
		if (srcW.annotations[i] != '') {
			var item = jNode.appendChild(iq.getDoc().createElement('item'));
			item.setAttribute('jid',i);
			item.appendChild(iq.getDoc().createTextNode(srcW.annotations[i]));
		}

	srcW.Debug.log(iq.getDoc().xml,3);
	srcW.con.syncSend(iq);
}

onload = init;
onunload = saveNotes;
      //-->
    </script>
  </head>
  <body style="margin:8px;">
		<table width="100%" height="100%">
				<tr><td><h2 id="title"></h2></td></tr>
				<tr><td width="100%" height="100%"><textarea id="note" style="height:100%;width:100%;"></textarea></td></tr>
		</table>
  </body>
</html>
